from packages.formats import csvfile as Csv


def main():
    dict_data = [
        {'name': '张三', 'age': 18},
        {'name': '张三1', 'age': 19},
        {'name': '张三2', 'age': 20},
        {'name': '张三3', 'age': 21},
    ]

    csv_handle = Csv.Csv('datas/example.csv')
    csv_handle.write_csv_head(['name', 'age'])
    csv_handle.write_csv_row(['name', 'age'], dict_data)
    csv_handle.write_csv_row(['name', 'age'], dict_data)
    csv_handle.write_csv_row(['name', 'age'], dict_data)
    csv_handle.write_csv_row(['name', 'age'], dict_data)
    results = csv_handle.read_csv()
    if results:
        print(results)
    csv_handle.close_csv()


if __name__ == '__main__':
    main()